<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Error</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="errorexception.getseverity.html">« ErrorException::getSeverity</a></li>
      <li style="float: right;"><a href="error.construct.html">Error::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="reserved.exceptions.html">预定义异常</a></li>
    <li>Error</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.error" class="reference">
 <h1 class="title">Error</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 7, PHP 8)</p>


  <div class="section" id="error.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    <span class="ooclass"><strong class="classname">Error</strong></span> 是所有PHP内部错误类的基类。
   </p>
  </div>


  <div class="section" id="error.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">Error</strong>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.throwable.html" class="interfacename">Throwable</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">protected</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.error.html#error.props.message">$<var class="varname">message</var></a></var><span class="initializer"> = &quot;&quot;</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">private</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.error.html#error.props.string">$<var class="varname">string</var></a></var><span class="initializer"> = &quot;&quot;</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
     <span class="type">int</span>
      <var class="varname"><a href="class.error.html#error.props.code">$<var class="varname">code</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.error.html#error.props.file">$<var class="varname">file</var></a></var><span class="initializer"> = &quot;&quot;</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
     <span class="type">int</span>
      <var class="varname"><a href="class.error.html#error.props.line">$<var class="varname">line</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">private</span>
     <span class="type">array</span>
      <var class="varname"><a href="class.error.html#error.props.trace">$<var class="varname">trace</var></a></var><span class="initializer"> = []</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">private</span>
     <span class="type">?</span><span class="type"><span class="type"><a href="class.throwable.html" class="type Throwable">Throwable</a></span><span class="type"></span></span>
      <var class="varname"><a href="class.error.html#error.props.previous">$<var class="varname">previous</var></a></var><span class="initializer"> = null</span>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="error.construct.html" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$message</code><span class="initializer"> = &quot;&quot;</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$code</code><span class="initializer"> = 0</span></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type"><a href="class.throwable.html" class="type Throwable">Throwable</a></span><span class="type"></span></span> <code class="parameter">$previous</code><span class="initializer"> = <strong><code>null</code></strong></span></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><a href="error.getmessage.html" class="methodname">getMessage</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><a href="error.getprevious.html" class="methodname">getPrevious</a></span>(): <span class="type"><span class="type">?</span><span class="type"><a href="class.throwable.html" class="type Throwable">Throwable</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><a href="error.getcode.html" class="methodname">getCode</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><a href="error.getfile.html" class="methodname">getFile</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><a href="error.getline.html" class="methodname">getLine</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><a href="error.gettrace.html" class="methodname">getTrace</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><a href="error.gettraceasstring.html" class="methodname">getTraceAsString</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="error.tostring.html" class="methodname">__toString</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">private</span> <span class="methodname"><a href="error.clone.html" class="methodname">__clone</a></span>(): <span class="type"><span class="type void">void</span></span></div>

   }</div>



  </div>
  
    <div class="section" id="error.props">
     <h2 class="title">属性</h2>
     <dl>
      
       <dt id="error.props.message"><var class="varname">message</var></dt>

       <dd>

        <p class="para">错误消息内容</p>
       </dd>

      
      
       <dt id="error.props.code"><var class="varname">code</var></dt>

       <dd>

        <p class="para">错误代码</p>
       </dd>

      
      
       <dt id="error.props.file"><var class="varname">file</var></dt>

       <dd>

        <p class="para">抛出错误的文件名</p>
       </dd>

      
      
       <dt id="error.props.line"><var class="varname">line</var></dt>

       <dd>

        <p class="para">抛出错误的行数</p>
        </dd>

      
      
       <dt id="error.props.previous"><var class="varname">previous</var></dt>

       <dd>

        <p class="para">之前抛出的异常</p>
       </dd>

      
      
       <dt id="error.props.string"><var class="varname">string</var></dt>

       <dd>

        <p class="para">字符串形式的堆栈跟踪</p>
       </dd>

      
      
       <dt id="error.props.trace"><var class="varname">trace</var></dt>

       <dd>

        <p class="para">数组形式的堆栈跟踪</p>
       </dd>

      
     </dl>

    </div>
  

 </div>







 









 









 









 









 









 



















 









 











<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="error.construct.html">Error::__construct</a> — 初始化 error 对象</li><li><a href="error.getmessage.html">Error::getMessage</a> — 获取错误信息</li><li><a href="error.getprevious.html">Error::getPrevious</a> — 返回先前的 Throwable</li><li><a href="error.getcode.html">Error::getCode</a> — 获取错误代码</li><li><a href="error.getfile.html">Error::getFile</a> — 获取错误发生时的文件</li><li><a href="error.getline.html">Error::getLine</a> — 获取错误发生时的行号</li><li><a href="error.gettrace.html">Error::getTrace</a> — 获取调用栈（stack trace）</li><li><a href="error.gettraceasstring.html">Error::getTraceAsString</a> — 获取字符串形式的调用栈（stack trace）</li><li><a href="error.tostring.html">Error::__toString</a> — error 的字符串表达</li><li><a href="error.clone.html">Error::__clone</a> — 克隆 error</li></ul>
</div>
</div></div></body></html>